home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / hard / drivr / LCD_102.lha / io08dev.lha / IO_Library / io_Test.c next >
C/C++ Source or Header  |  1995-06-21  |  5KB  |  296 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/misc.h>
  5. #include <proto/io.h>
  6. #include <stdio.h>
  7.  
  8.  
  9. struct Library *IOBase;
  10.  
  11.  
  12. extern struct Custom __far custom;
  13. extern struct CIA    __far ciaa, ciab;
  14.  
  15. int res,val,val2,a,b,c,d;
  16. long delayint, delayint2;
  17.  
  18.  
  19. UBYTE prova,testo;
  20.  
  21. WORD txt;
  22.  
  23. int main( int argc, char *argv[] )
  24. {
  25.  
  26.     val = 1;
  27.  
  28.  
  29.     val2 = 4;
  30.  
  31.     delayint = 1;
  32.     delayint2 = 1;
  33.  
  34.     IOBase = OpenLibrary("io.library",0);
  35.  
  36.     if(IOBase)
  37.     {
  38.  
  39.  
  40.         io_SetParDir(0xFF);
  41.  
  42.         io_SetExtParDir(0xFF);
  43.  
  44.         io_ResetPar();
  45.  
  46.         io_ResetExtPar();
  47.  
  48.         if((strstr(argv[1],"G1")) != NULL)
  49.         {
  50.             for(a = 0; a <= 10 ; a++)
  51.             {
  52.  
  53.             io_WriteParA(0,1);Delay(delayint);
  54.             io_WriteParA(1,1);Delay(delayint);
  55.             io_WriteParA(0,0);Delay(delayint);
  56.             io_WriteParA(2,1);Delay(delayint);
  57.             io_WriteParA(1,0);Delay(delayint);
  58.             io_WriteParA(3,1);Delay(delayint);
  59.             io_WriteParA(2,0);Delay(delayint);
  60.             io_WriteParA(4,1);Delay(delayint);
  61.             io_WriteParA(3,0);Delay(delayint);
  62.             io_WriteParA(5,1);Delay(delayint);
  63.             io_WriteParA(4,0);Delay(delayint);
  64.             io_WriteParA(6,1);Delay(delayint);
  65.             io_WriteParA(5,0);Delay(delayint);
  66.             io_WriteParA(7,1);Delay(delayint);
  67.             io_WriteParA(6,0);Delay(delayint);
  68.             io_WriteExtParA(0,1);Delay(delayint);
  69.             io_WriteParA(7,0);Delay(delayint);
  70.             io_WriteExtParA(1,1);Delay(delayint);
  71.             io_WriteExtParA(0,0);Delay(delayint);
  72.             io_WriteExtParA(2,1);Delay(delayint);
  73.             io_WriteExtParA(1,0);Delay(delayint);
  74.             io_WriteExtParA(2,0);Delay(delayint);
  75.         
  76.             }
  77.         }
  78.  
  79.         if((strstr(argv[1],"G2")) != NULL)
  80.         {
  81.             for(a = 0; a <= 10 ; a++)
  82.             {
  83.                 io_WriteParA(0,0);
  84.                 io_WriteParA(2,0);
  85.                 io_WriteParA(4,0);
  86.                 io_WriteParA(6,0);
  87.                 io_WriteExtParA(0,0);    
  88.                 io_WriteExtParA(2,0);
  89.  
  90.                 io_WriteParA(1,1);
  91.                 io_WriteParA(3,1);
  92.                 io_WriteParA(5,1);
  93.                 io_WriteParA(7,1);
  94.                 io_WriteExtParA(1,1);    
  95.  
  96.                 Delay(15);
  97.             
  98.                 io_WriteParA(0,1);
  99.                 io_WriteParA(2,1);
  100.                 io_WriteParA(4,1);
  101.                 io_WriteParA(6,1);
  102.                 io_WriteExtParA(0,1);    
  103.                 io_WriteExtParA(2,1);
  104.  
  105.                 
  106.                 io_WriteParA(1,0);
  107.                 io_WriteParA(3,0);
  108.                 io_WriteParA(5,0);
  109.                 io_WriteParA(7,0);
  110.                 io_WriteExtParA(1,0);
  111.  
  112.  
  113.                 Delay(15);
  114.  
  115.             }
  116.  
  117.                 io_WriteParA(0,0);
  118.                 io_WriteParA(2,0);
  119.                 io_WriteParA(4,0);
  120.                 io_WriteParA(6,0);
  121.                 io_WriteExtParA(0,0);    
  122.                 io_WriteExtParA(2,0);
  123.             
  124.  
  125.         }    
  126.  
  127.         if((strstr(argv[1],"G3")) != NULL)
  128.         {
  129.             for(a = 0; a <= 10 ; a++)
  130.             {
  131.         
  132.             io_WriteParA(0,1);Delay(delayint2);
  133.             io_WriteParA(0,0);
  134.             io_WriteParA(1,1);Delay(delayint2);
  135.             io_WriteParA(1,0);
  136.             io_WriteParA(2,1);Delay(delayint2);
  137.             io_WriteParA(2,0);
  138.             io_WriteParA(3,1);Delay(delayint2);
  139.             io_WriteParA(3,0);            
  140.             io_WriteParA(4,1);Delay(delayint2);
  141.             io_WriteParA(4,0);
  142.             io_WriteParA(5,1);Delay(delayint2);
  143.             io_WriteParA(5,0);            
  144.             io_WriteParA(6,1);Delay(delayint2);
  145.             io_WriteParA(6,0);
  146.             io_WriteParA(7,1);Delay(delayint2);
  147.             io_WriteParA(7,0);
  148.             io_WriteExtParA(0,1);Delay(delayint2);
  149.             io_WriteExtParA(0,0);
  150.             io_WriteExtParA(1,1);Delay(delayint2);
  151.             io_WriteExtParA(1,0);
  152.             io_WriteExtParA(2,1);Delay(delayint2);
  153.             io_WriteExtParA(2,0);    
  154.             io_WriteExtParA(1,1);Delay(delayint2);
  155.             io_WriteExtParA(1,0);
  156.             io_WriteExtParA(0,1);Delay(delayint2);
  157.             io_WriteExtParA(0,0);        
  158.             io_WriteParA(6,1);Delay(delayint2);
  159.             io_WriteParA(6,0);
  160.             io_WriteParA(5,1);Delay(delayint2);
  161.             io_WriteParA(5,0);            
  162.             io_WriteParA(4,1);Delay(delayint2);
  163.             io_WriteParA(4,0);
  164.             io_WriteParA(3,1);Delay(delayint2);
  165.             io_WriteParA(3,0);            
  166.             io_WriteParA(2,1);Delay(delayint2);
  167.             io_WriteParA(2,0);            
  168.             io_WriteParA(1,1);Delay(delayint2);
  169.             io_WriteParA(1,0);
  170.             io_WriteParA(0,1);Delay(delayint2);
  171.             io_WriteParA(0,0);            
  172.  
  173.             }
  174.         }
  175.  
  176.         if((strstr(argv[1],"G4")) != NULL)
  177.         {
  178.  
  179.             io_WriteParA(0,0);
  180.  
  181.             b = io_ReadParA(0);
  182.  
  183.             printf("Stato: %d\n",b);
  184.             
  185.             Delay(50);
  186.  
  187.             io_WriteParA(0,1);
  188.  
  189.             b = io_ReadParA(0);
  190.  
  191.             printf("Stato: %d\n",b);
  192.  
  193.         
  194.  
  195.         }
  196.  
  197.         if((strstr(argv[1],"G5")) != NULL)
  198.         {
  199.             b=0;
  200.             
  201.             PutStr("Wait 1 secs\n");
  202.  
  203.             Delay(50);
  204.  
  205.  
  206.             b = io_AllocParPort();    
  207.  
  208.             printf("Ret: %d\n",b);
  209.  
  210.             Delay(50);
  211.  
  212.             io_FreeParPort();
  213.  
  214.         }
  215.  
  216.         if((strstr(argv[1],"G6")) != NULL)
  217.         {
  218.     
  219.             io_WriteLed(0);
  220.  
  221.             Delay(50);
  222.  
  223.             io_WriteLed(1);
  224.  
  225.         }    
  226.  
  227.         if((strstr(argv[1],"SER")) != NULL)
  228.         {
  229.  
  230.             io_SetSerBaud(300,0,1);
  231.  
  232.             io_WriteSer("A");
  233.         
  234.         } 
  235.  
  236.         if((strstr(argv[1],"SER2")) != NULL)
  237.         {
  238.  
  239.             io_SetSerBaud(19200,0,0);
  240.  
  241.             io_WriteSer("AT\n");
  242.         
  243.         } 
  244.  
  245.         if((strstr(argv[1],"SER3")) != NULL)
  246.         {
  247.     
  248.             io_SetSerBaud(19200,0,0);
  249.  
  250.             for(c = 0; c <= 200; c++)
  251.  
  252.             {
  253.  
  254.                 testo = io_ReadSer();
  255.  
  256.                 PutStr(testo);
  257.  
  258.             }        
  259.         }
  260.  
  261.         if((strstr(argv[1],"JOY1")) != NULL)
  262.         {
  263.  
  264.             int a,b;
  265.  
  266.             io_SetJoy1DirA(2,0);
  267.             io_SetJoy1DirA(0,0);
  268.  
  269.             a = b = 0;
  270.             
  271.  
  272.             b = io_ReadJoy1A(0);
  273.  
  274.             a = io_ReadJoy1A(2);
  275.  
  276.  
  277.  
  278.             printf("Fire1 = %d\n", a );
  279.             printf("Fire2 = %d\n", b );
  280.  
  281.  
  282.  
  283.         }    
  284.  
  285.         CloseLibrary(IOBase);
  286.  
  287.     }
  288.  
  289.  
  290.     return(0);
  291.  
  292. }
  293.  
  294.  
  295.  
  296.